JavaScript

listObj.setOrder Method

Syntax

listObj.setOrder(settingsObject);

Arguments

settingsObjectJSON objectarray

An object or array that defines how to sort the List.

Description

Sort the List client-side.

Discussion

Performs a client-side sort of the data in the List. You can sort on multiple fields. In the case where you want to sort on multiple fields, you should pass in an array (not an object) to define the sort (see examples below.)

var listObj = {dialog.object}.getControl('LIST1');

if (listObj) {
    //Sort on the first character of the Country field
    listObj.setOrder({'Country:first:1' : 1});

    //Sort on the DateOfBirth fields (you must specify the date format)
    listObj.setOrder({'DateOfBirth:date:MM-dd-yyyy' : 1});

    //Un-sort the List (to get back to its natural order)
    listObj.setOrder(false);

    //Sort on Country ascending and then within Country, by City descending
    var sortObj = [ ['Country',1], ['City' , -1]];
    listObj.setOrder(sortObj);

    //the value of 1 is assumed if omitted, so the following is same as above example
    var sortObj = [ 'Country', ['City' , -1]];
    listObj.setOrder(sortObj);

    // Sort the list using the field the user selected in a Dropdown Box:
    var sortField = {dialog.object}.getValue("SORT_FIELD_DROPDOWN");
    var sortObj = [sortField];
    listObj.setOrder(sortObj);
}

See Also